﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Security;
using System.Security.Cryptography;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for EncryptRSA
/// </summary>
public class EncryptRSA
{
    /*
    String _data;
    public String Data
    {
        get { return _data; }
        set { _data = value; }
    }

    String XmlPubKey;
    String XmlPriKey;

    byte[] dataToEncrypt;
    byte[] encryptedData;
    byte[] decryptedData;

    RSACryptoServiceProvider RSA;

	public EncryptRSA()
	{
        RSA = new RSACryptoServiceProvider();
        dataToEncrypt = ByteConverter.GetBytes(Data);
	}

    public String RSAEncrypt()
    {
        try
        {
            StreamReader r = new StreamReader("rsaPubkey.xml");
            XmlPubKey = r.ReadToEnd();
            r.Close();
            //Create a new instance of RSACryptoServiceProvider.
            RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();

            //Import the RSA Key information. This only needs
            //toinclude the public key information.
            //RSA.ImportParameters(RSAKeyInfo);
            RSA.FromXmlString(XmlPubKey);

            //Encrypt the passed byte array and specify OAEP padding.  
            //OAEP padding is only available on Microsoft Windows XP or
            //later.  
            return ByteConverter.GetString(RSA.Encrypt(dataToEncrypt, true));
        }
        //Catch and display a CryptographicException  
        //to the console.
        catch (CryptographicException e)
        {
            return null;
        }

    }
    */
}
